#!/usr/bin/env python
# coding:utf-8
# @author heitfei
# 2017-06-04 01:33:18

'''
tcp time client tcp using socket
'''

import socket

HOST = 'localhost'
PORT = 23567
BUFFSIZE = 1024
ADDR = (HOST, PORT)

while True:
    data = raw_input('> ')
    tsCliSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
    tsCliSocket.connect(ADDR)
    if not data:
        break
    tsCliSocket.send(data)
    data = tsCliSocket.recv(BUFFSIZE)
    if not data:
        break
    print data
    tsCliSocket.close()
